package polymorphism;

import inherit.C;

/**
 * @author yuisama
 * @date 2022/09/14 19:58
 **/
public class SharpTest {
    public static void main(String[] args) {
        // 假设没有向上转型
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Tran tran = new Tran();
        Flower flower = new Flower();
        // 形状的对象数组
        Sharp[] sharps = {new Flower(),new Cycle(),new Tran(),new Rect(),new Rhombus()};
        for (Sharp sharp : sharps) {
            sharp.draw();
        }
//        String[] sharpes = {"cycle","tran","rect","flower"};
//        for (String str :  sharpes) {
//            if (str.equals("rect")) {
//                rect.draw();
//            }else if (str.equals("cycle")) {
//                cycle.draw();
//            }else if (str.equals("tran")) {
//                tran.draw();
//            }else if (str.equals("flower")) {
//                flower.draw();
//            }
//        }
    }
}